package com.link.base.base.member.controller;

import com.link.base.base.member.model.GiftCardWx;
import com.link.base.base.member.service.GiftCardWxService;
import com.link.core.basic.controller.BasicController;
import com.link.core.basic.service.BasicService;
import com.link.core.basic.service.KeyGenerateService;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;

import javax.annotation.Resource;
import java.util.HashMap;
import java.util.Map;

/**
 * 货架打通小程序
 *
 * @author 路江
 * @date 2019/03/04 18:01
 */
@Controller
@RequestMapping("/link/giftCardWx")
public class GiftCardWxController extends BasicController<GiftCardWx> {
 
    @Resource
    private KeyGenerateService keyGenerateService;

    @Resource
    private GiftCardWxService giftCardWxService;

    @Override
    public BasicService<GiftCardWx> getBasicService() throws Exception {
        return giftCardWxService;
    }

    /**
     * 打通礼品券货架和小程序
     *
     * @author lujiang
     * @date 2019-03-04
     * @param giftCardWx 礼品券和小程序中间表对象
     * @return
     * @throws Exception
     */
    @RequestMapping(value = "/setGiftCardWxa")
    @ResponseBody
    public Map<String, Object> setGiftCardWxa(@RequestBody GiftCardWx giftCardWx) throws Exception {
        Map<String, Object> result = new HashMap<>(16) ;
        try {
            result = giftCardWxService.setGiftCardWxa(giftCardWx);
            result.put("success",true);
        } catch (Exception e) {
            result.put("success",false);
            result.put("msg",e.getMessage());
        }
        return result;
    }
}
